package com.wubotao.algorithm;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Bubble {

	public static <E extends Comparable<? super E>> void sort(List<E> list) {
		for (int index = list.size() - 1; index > 0; index--) {
			for (int time = 0; time < index; time++) {
				if (list.get(time).compareTo(list.get(time + 1)) > 0) {
					Collections.swap(list, time, time + 1);
				}
			}
		}
	}

	public static void main(String[] args) {
		List<Integer> list = Arrays.asList(5, 69, 12, 3, 56, 789, 2, 5648, 23);
		sort(list);
		System.out.println(list);
	}

}

